package com.briup.web.controller;

import com.briup.DTO.AddOrUpdateQuarantimeRegistraionDTO;
import com.briup.DTO.SaveOrUpdateDiseaseRecordDTO;
import com.briup.annotation.SystemLog;
import com.briup.exception.SystemException;
import com.briup.mapper.DiseaseMapper;
import com.briup.pojo.Disease;
import com.briup.pojo.DiseaseRecord;
import com.briup.result.PageTemplate;
import com.briup.result.Result;
import com.briup.service.DiseaseRecordService;
import com.briup.service.DiseaseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.logging.log4j.message.ReusableMessage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin
@Slf4j
@Api(tags = "病症模块")
@RequestMapping("/diseaseRecord")
public class DiseaseRecordController {
    @Autowired
    private DiseaseRecordService diseaseRecordService;
@Autowired
private DiseaseService diseaseService;
    @GetMapping("/queryAllDisease")
    @ApiOperation("查询所有病症类型信息")
    public Result queryAllDisease(){
        List<Disease> list = diseaseService.list();
        return Result.success(list);
    }
    @GetMapping("/query")
    @ApiOperation("分页多条件查询病症记录")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum",value = "当前页码"),
            @ApiImplicitParam(name = "pageSize",value = "每页大小"),
            @ApiImplicitParam(name = "bQualified",value = "检疫结果：合格或不合格"),
            @ApiImplicitParam(name = "grMechanism",value = "检疫机构，支持模糊查询")
    })
    public Result query(Integer pageNum,Integer pageSize,String drDId,String drStatus) throws SystemException {
        PageTemplate pageTemplate=diseaseRecordService.qrquery(pageNum,pageSize,drDId,drStatus);
        return Result.success(pageTemplate);
    }
    @DeleteMapping("/deleteById")
    @ApiOperation("根据id删除病症信息接口")
    @SystemLog(business = "根据id删除病症信息")
    public Result deleteById(@PathVariable String id) throws SystemException {
        return diseaseRecordService.deleteById(id);
    }
    @DeleteMapping("deleteByIdAll")
    @ApiOperation("批量删除病症信息接口")
    @SystemLog(business = "批量删除病症信息")
    public Result deleteByIdAll(@RequestBody List<String> ids) throws SystemException {
        return diseaseRecordService.deleteByIdAll(ids);
    }
    @PostMapping("/saveOrUpdate")
    @ApiOperation("新增或更新病症记录接口")
    @SystemLog(business = "新增或更新病症记录")
    public Result saveOrUpdate(@RequestBody SaveOrUpdateDiseaseRecordDTO saveOrUpdateDiseaseRecordDTO) throws SystemException {
        return diseaseRecordService.DRSaveOrUpdate(saveOrUpdateDiseaseRecordDTO);
    }
}
